package com.study.studyroom.entity.enums;

/**
 * 计费单位
 */
public enum UnitTypeEnum {
    MINUTES(1,"每分钟",60*1000),
    HOURS(2,"每小时",60*60*1000),
    DAY(3,"每天",24*60*60*1000),
    WEEK(4,"每周",7*24*60*60*1000),
    MONTH(5,"每月", 31L *24*60*60*1000),
    YEAR(6,"每年", 366L *24*60*60*1000);

    private final int code;

    private final String desc;

    private final long formula;

    UnitTypeEnum(int code, String desc,long formula) {
        this.code = code;
        this.desc = desc;
        this.formula = formula;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public long getFormula() {
        return formula;
    }

    public static UnitTypeEnum getByCode(int code){
        for (UnitTypeEnum value : UnitTypeEnum.values()) {
            if (code==value.code){
                return value;
            }
        }
        return UnitTypeEnum.MINUTES;
    }
}
